package
{
	import flash.system.ApplicationDomain;
	
	import starling.animation.Juggler;
	import starling.core.Starling;
	import starling.display.Image;
	import starling.display.MovieClip;
	import starling.display.Sprite;
	import starling.events.Event;
	import starling.textures.Texture;
	
	import utils.LayerUtils;
	import utils.LevelConfigXmlUtils;
	
	public class Main extends Sprite
	{
		private var preload:PreloadScreen;
		public function Main()
		{
			super();
			addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
		}
		
		private function onAddedToStage(event:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
			init();
		}
		
		private function init():void{
			LayerUtils.getInstance().start(stage);
			
			preload = new PreloadScreen();
			addChild(preload);
			preload.addEventListener(starling.events.Event.COMPLETE,onLoadComplete);
		}
		
		private function onLoadComplete(e:Event):void
		{	
			//保存资源关卡数据到关卡数据类中
//			var tempCls:Class = Assets.getClass("Resource_LevelXml");
//			LevelConfigXmlUtils.getInstance().xml = XML(new tempCls());
			
			trace(Assets.getClass("Resource"));
			
			removeChild(preload);
			addChild(new InGame());
		}
	}
}